import random

def generate_triangle(levels=4, value_range=(1, 9)):
    triangle = []
    for i in range(1, levels + 1):
        row = [random.randint(value_range[0], value_range[1]) for _ in range(i)]
        triangle.append(row)
    return triangle
if __name__ == "__main__":
    print("函数测试：", generate_triangle())
